<template>
    <view>
        <view v-if="plugins_yxformplus_data != null" class="">
            <!-- 商品 -->
			<view v-for="(yxitem, index) in plugins_yxformplus_data" :key="index" class="goods-item br-b-dashed oh padding-main">
				<block v-if="yxitem.goods_id == params.goods_id">
					<view class="goods padding-main border-radius-main bg-white spacing-mb">
						<view class="goods-item oh">
							<navigator :url="'/pages/goods-detail/goods-detail?id=' + yxitem.goods_id" hover-class="none">
								<image class="goods-image fl radius" :src="yxitem.images" mode="aspectFill"></image>
								<view class="goods-base">
									<view class="multi-text">{{yxitem.title}}</view>
									<view v-if="yxitem.spec_text != null" class="margin-top-sm">
										<text class="cr-grey">{{yxitem.spec_text}}</text>
									</view>
									<view class="margin-top-sm">
										<text class="fw-b">{{yxitem.currency_data.currency_symbol}}{{yxitem.price}}</text>
										<text class="margin-left-sm">x{{yxitem.buy_number}}</text>
									</view>
								</view>
							</navigator>
						</view>
					</view>
					<view class="yxformplus_edit_tips" v-if="yxitem.form_allow_edit > 0"></view>
					<view class="yxformplus_edit_tips jinzhi" v-else>当前表单已不能再次编辑</view>
					
					<!--自定义表单插件-->
					<block v-if="(yxitem.form_data || null) != null && yxitem.form_allow_edit > 0">
						<view class="goods-spec-choose plugins-yxformplus bg-white padding-main border-radius-main">
							<view v-for="(item, key) in yxitem.form_data" :key="key" class="item br-b">
								<view class="title">{{item.name}}</view>
								<block v-if="item.can_edit > 0">
								<view class="spec">
									<!--文本类-->
									<block v-if="item.type == 1">
										<input type="text" :placeholder="item.field_info.tishi_text" :name="'input_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" class="form-item margin-vertical-main wh-auto yxformplus-item" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :value="item.field_info.moren" :data-validation-message="'请输入'+item.field_info.name" @blur="yxblur" @confirm="yxblur" :data-index="key" :maxlength="(item.field_info.maxlength == 0) ? -1 : item.field_info.maxlength" :data-id="item.id">
									</block>
									<!--多行文本类-->
									<block v-if="item.type == 2">
										<textarea :placeholder="item.field_info.tishi_text" :name="'textarea_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" class="form-item margin-vertical-main wh-auto yxformplus-item" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :auto-height="true" :value="item.field_info.moren" :data-validation-message="item.field_info.name+'不能为空'" @blur="yxblur" @confirm="yxblur" :data-index="key" :maxlength="(item.field_info.maxlength == 0) ? -1 : item.field_info.maxlength" :data-id="item.id"></textarea>
									</block>
									<!--整数类-->
									<block v-if="item.type == 3">
										<input type="number" :placeholder="item.field_info.tishi_text" :name="'input_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" class="form-item margin-vertical-main wh-auto yxformplus-item" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :value="item.field_info.moren" :data-validation-message="'请输入'+item.field_info.name" @blur="yxblur" @confirm="yxblur" :data-index="key" :maxlength="(item.field_info.maxlength == 0) ? -1 : item.field_info.maxlength" :data-id="item.id">
									</block>
									<!--单选-->
									<block v-if="item.type == 4 && (item.field_info.danxuan || null != null)">
										<view class="uni-list">
											<radio-group @change="yxonclick" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-validation-message="item.field_info.name+'必选'" :data-index="key" :data-id="item.id">
												<label class="yxradio" v-for="(items, indexs) in item.field_info.danxuan" :key="indexs">
													<radio :value="items.value" :checked="items.checked != ''" :color="theme_color" :name="'radio_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" />{{items.name}}
												</label>
											</radio-group>
										</view>
									</block>
									<!--多选-->
									<block v-if="item.type == 5 && (item.field_info.duoxuan || null != null)">
										<view class="uni-list">
											<checkbox-group @change="yxonclick" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-validation-message="item.field_info.name+'必选'" :data-index="key" :data-id="item.id">
												<label class="yxcheckbox" v-for="(items, indexs) in item.field_info.duoxuan" :key="indexs">
													<checkbox :value="items.value" :checked="items.checked != ''" :color="theme_color" :name="'radio_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" />{{items.name}}
												</label>
											</checkbox-group>
										</view>
									</block>
									<!--下拉-->
									<block v-if="item.type == 6 && (item.field_info.xiala || null != null)">
										<view class="yxsection">
											<picker :name="'select_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" @change="yxselect" :value="yxxiala_value[key]" :range="item.field_info.xiala" range-key="name" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-validation-message="item.field_info.name+'必选'" :data-index="key" :data-id="item.id">
												<view :class="'name ' + ((yxxiala_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{(yxxiala_value[key] == null) ? '请选择' : (((item.field_info.xiala[yxxiala_value[key]] || null) == null) ? item.field_info.default_value : item.field_info.xiala[yxxiala_value[key]]['name'])}}</view>
											</picker>
										</view>
									</block>
									<!--日期-->
									<block v-if="item.type == 7">
										<view class="yxsection">
											<picker mode="date" :value="(item.field_info.moren || null) != null ? item.field_info.moren : 0" @change="bindDateChange" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-validation-message="item.field_info.name+'必选'" :data-index="key" :data-id="item.id">
												<view class="uni-input">{{item.field_info.moren}}</view>
											</picker>
										</view>
									</block>
									<!--时间-->
									<block v-if="item.type == 8">
										<view class="yxsection">
											<picker mode="time" :value="item.field_info.moren" @change="bindDateChange" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-validation-message="item.field_info.name+'必选'" :data-index="key" :data-id="item.id">
												<view class="uni-input">{{item.field_info.moren}}</view>
											</picker>
										</view>
									</block>
									<!--附件-->
									<block v-if="item.type == 9 || item.type == 10">
										<view class="yxfile">
											<view class="form-upload-data fl">
												<block v-if="(yxfile[key] || null) != null && yxfile[key].length > 0">
													<view v-for="(items, ix) in yxfile[key]" :key="ix" class="picitem fl">
														<text class="delete-icon" @tap="upload_delete_event" :data-index="key" :data-ix="ix" :data-file_type="item.field_info.file_type" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-max-number="item.field_info.max_num" :data-id="item.id">x</text>
														<block v-if="item.file_type == 'images'">
															<image :src="items" @tap="upload_show_event" :data-index="key" :data-ix="ix" mode="aspectFill" class="padding-xs dis-block"></image>
														</block>
														<block v-else-if="item.file_type == 'video'">
															<video :src="items" :show-center-play-btn="true" :controls="false" :show-play-btn="false" :enable-progress-gesture="false" :show-fullscreen-btn="false"></video>
														</block>
														<block v-else>
															<view class="wendangbox">{{item.field_info.name}}{{ix}}</view>
														</block>
													</view>
												</block>
											</view>
											<image v-if="(yxfile[key] || null) == null || yxfile[key].length < item.field_info.max_num" class="upload-icon" :src="common_static_url+'upload-icon.png'" mode="aspectFill" @tap="file_upload_event" :data-index="key" :data-file_type="item.field_info.file_type" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-is_must="item.field_info.is_must" :data-max-number="item.field_info.max_num" :data-validation-message="item.field_info.name+'必须上传'" :data-id="item.id"></image>
											<view class="c_b"> </view>
										</view>
									</block>
									<!--金钱货币-->
									<block v-if="item.type == 11">
										<input type="digit" :placeholder="item.field_info.tishi_text" :name="'input_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" class="form-item margin-vertical-main wh-auto yxformplus-item" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :value="item.field_info.moren" @blur="yxblur" @confirm="yxblur" :data-validation-message="'请输入正确的'+item.field_info.name" :data-index="key" :maxlength="(item.field_info.maxlength == 0) ? -1 : item.field_info.maxlength" :data-id="item.id">
									</block>
									<!--三级地址-->
									<block v-if="item.type == 12">
										<view class="select-address oh">
											<view class="section fl">
												<picker :name="'province_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" @change="select_province_event" :value="(province_value[key] || null != null) ? province_value[key] : 0" :range="province_list[key]" range-key="name" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :data-index="key" :data-validation-message="item.field_info.name+'必选'" :data-id="item.id">
													<view :class="'name ' + ((province_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{(province_value[key] == null) ? default_province : (((province_list[key][province_value[key]] || null) == null) ? default_province : province_list[key][province_value[key]]['name'])}}</view>
												</picker>
											</view>
											<view class="section fl">
												<picker v-if="(city_list[key] || null) != null" :name="'city_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" @change="select_city_event" :value="city_value[key]" :range="city_list[key]" range-key="name" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :data-index="key" :data-id="item.id">
													<view :class="'name ' + ((city_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{((city_list[key][city_value[key]] || null) == null) ? default_city : city_list[key][city_value[key]]['name']}}</view>
												</picker>
												<text v-else class="cr-grey" @tap="region_select_error_event" data-value="请先选择省份" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :data-index="key" :data-id="item.id">请先选择省份</text>
											</view>
											<view class="section fl">
												<picker v-if="(county_list[key] || null) != null" :name="'county_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" @change="select_county_event" :value="county_value[key]" :range="county_list[key]" range-key="name" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :data-index="key" :data-id="item.id">
													<view :class="'name ' + ((county_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{((county_list[key][county_value[key]] || null) == null) ? default_county : county_list[key][county_value[key]]['name']}}</view>
												</picker>
												<text v-else class="cr-grey" @tap="region_select_error_event" data-value="请先选择城市" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :data-index="key" :data-id="item.id">请先选择城市</text>
											</view>
										</view>
									</block>
									<!--文本类-->
									<block v-if="item.type == 13">
										<view class="pr">
											<input type="text" :placeholder="item.field_info.tishi_text" :name="'input_'+item.field_info.sid+'_'+item.field_info.type+'_'+item.field_info.id" class="form-item margin-vertical-main wh-auto yxformplus-item" :data-form-id="item.field_info.sid" :data-type-id="item.field_info.type" :data-field-id="item.field_info.id" :data-title="item.field_info.name" :data-value="item.field_info.moren" :data-minlength="item.field_info.minlength" :data-maxlength="item.field_info.maxlength" :data-is_must="item.field_info.is_must" :value="item.field_info.moren" :data-validation-message="'请输入'+item.field_info.name" @tap="choose_location_event" :data-lng="item.field_info.jingweidu_lng || 0" :data-lat="item.field_info.jingweidu_lat || 0" :data-index="key" :maxlength="(item.field_info.maxlength == 0) ? -1 : item.field_info.maxlength" :data-id="item.id">
											<view class="map-icon pa cp tc">
												<uni-icons type="location" size="20" color="#666"></uni-icons>
											</view>
										</view>
									</block>
								</view>
								</block>
								<block v-else>
									<view class="spec">
										<!--附件-->
										<view v-if="item.type == 9 || item.type == 10">
											<view class="yxfile">
												<view class="form-upload-data fl">
													<block v-if="(yxfile[key] || null) != null && yxfile[key].length > 0">
														<view v-for="(items, ix) in yxfile[key]" :key="ix" class="picitem fl">
															<block v-if="item.file_type == 'images'">
																<image :src="items" @tap="upload_show_event" :data-index="key" :data-ix="ix" mode="aspectFill" class="padding-xs dis-block"></image>
															</block>
															<block v-else-if="item.file_type == 'video'">
																<video :src="items" :show-center-play-btn="true" :controls="false" :show-play-btn="false" :enable-progress-gesture="false" :show-fullscreen-btn="false"></video>
															</block>
															<block v-else>
																<view class="wendangbox">{{item.field_info.name}}{{ix}}</view>
															</block>
														</view>
													</block>
												</view>
												<text class="jinbian">(该字段禁止编辑)</text>
												<view class="c_b"> </view>
											</view>
										</view>
										<view v-else>
											<mp-html :content="item.content_value" /><text class="jinbian">(该字段禁止编辑)</text>
										</view>
									</view>
								</block>
							</view>
							<button class="goods-popup-submit cr-white" :style="'background:'+diytheme.main_color+';border:1px solid '+diytheme.main_color+';'" type="default" @tap.stop="goods_buy_confirm_event" hover-class="none">确定</button>
						</view>
					</block>
				</block>
			</view>
        </view>
        <view v-else>
            <!-- 提示信息 -->
            <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
        </view>
		<!-- #ifdef APP-PLUS -->
		<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></yk-authpup>
		<!-- #endif -->
    </view>
</template>
<script>
    const app = getApp();
	// #ifdef APP-PLUS
	import ykAuthpup from "@/components/yk-authpup/yk-authpup";
	// #endif
    import componentPopup from "@/components/popup/popup";
    import componentNoData from "@/components/no-data/no-data";
    import componentBottomLine from "@/components/bottom-line/bottom-line";
	import {system_base_info} from "@/common/js/common/common";
    var common_static_url = app.globalData.get_static_url('common');
	
	// 得到主题名字
	var theme_name = app.globalData.data.default_theme;
    export default {
        data() {
            return {
                common_static_url: common_static_url,
                params: null,
                data_list_loding_status: 1,
                data_list_loding_msg: '',
                data_bottom_line_status: false,
				
                // 接口数据
                editor_path_type: '',
                plugins_yxformplus_data: null,
				
				theme_color:(theme_name=='yellow') ? '#f6c133' : ((theme_name=='red') ? '#ff0036' : ((theme_name=='black') ? '#333333' : ((theme_name=='green') ? '#20a53a' : ((theme_name=='orange') ? '#fe6f04' : ((theme_name=='blue') ? '#1677ff' : ((theme_name=='brown') ? '#8B4513' : ((theme_name=='purple') ? '#623cec' : '#f6c133'))))))),
				province_list:[],
				city_list: [],
				county_list: [],
				province_id: [],
				city_id: [],
				county_id: [],
				default_province: "请选择省",
				default_city: "请选择市",
				default_county: "请选择区/县",
				province_value: [],
				city_value: [],
				county_value: [],
				yxfile:[],
				yxxiala:[],//下拉列表数据
				yxxiala_value:[],//下拉选中数据对应的数组序号
				editor_path_type:'',
				user_location_cache_key: app.globalData.data.cache_userlocation_key,
				permissionID:'',
				peraction:'',
				diytheme:null,
				lang_info:null,
            };
        },

        components: {
			// #ifdef APP-PLUS
			ykAuthpup,
			// #endif
            componentPopup,
            componentNoData,
            componentBottomLine
        },
        props: {},

        onLoad(params) {
			//params['id'] = 5;
			//params['goods_id'] = 6;
            this.setData({
                params: params
            });
        },

        onShow() {
			app.globalData.page_event_onshow_handle();
			this.user_location_init();
			
            // 数据加载
            this.init();
        },

        // 下拉刷新
        onPullDownRefresh() {
            this.init();
        },

        methods: {
			// 加载之前
			init() {
				// 先获取语言基础信息
				system_base_info()
				.then(data=>{
					this.init_before(data)
					.then(()=>{
						this.init_real();
					});
				});
			},
			
			// 设置本页参数
			init_before(data){
				var self = this;
				return new Promise((resolve, reject) => {
					self.setData({
						lang_info: data.system_lang_info,
						diytheme: data.diytheme,
					});
					/*uni.setNavigationBarTitle({
					    title: data.index_page_title
					});*/
					resolve();
				});
			},
            // 获取数据
            init_real() {
                var self = this;
                uni.showLoading({
                    title: this.$t('common.loading_in_text'),
                });
                this.setData({
                    data_list_loding_status: 1
                });
                uni.request({
                    url: app.globalData.get_request_url("formdata", "index", "yxformplus"),
                    method: 'POST',
                    data: {
                        id: this.params.id,
                        goods_id: this.params.goods_id
                    },
                    dataType: 'json',
                    success: res => {
                        uni.hideLoading();
                        uni.stopPullDownRefresh();
                        if (res.data.code == 0) {
                            var data = res.data.data;
                            self.setData({
                                data_list_loding_status: 3,
                                data_bottom_line_status: true,
                                data_list_loding_msg: '',
                                editor_path_type: data.editor_path_type || '',
                                plugins_yxformplus_data: data.data || null,
                            });
							
							// 调用地址数据
							this.get_province_list();
							
							// 赋值初始化地址ID
							if(this.plugins_yxformplus_data || null != null){
								var temp_data_list= this.plugins_yxformplus_data[0].form_data;
								var temp_province = [];
								var temp_city = [];
								var temp_county = [];
								var i_arr = [];
								var temp_img_list = [];
								var img_t = [];
								var temp_picurl = [];
								var temp_xiala_list = [];
								for (var i in temp_data_list) {
									if(parseInt(temp_data_list[i]['type']) == 12){
										temp_province[i] = temp_data_list[i]['province'];
										temp_city[i] = temp_data_list[i]['city'];
										temp_county[i] = temp_data_list[i]['county'];
										
										i_arr.push(i);
									}else{
										temp_province[i] = [];
										temp_city[i] = [];
										temp_county[i] = [];
									}
									
									// 存储的附件
									temp_picurl = [];
									temp_img_list[i] = [];
									if((temp_data_list[i].picurl || null != null) && temp_data_list[i].picurl.length > 0){
										temp_picurl = temp_data_list[i].picurl;
										img_t = [];
										for (var j in temp_picurl) {
											img_t.push(temp_picurl[j]['images']);// 只保留远程路径，存为一个数组
										}
										temp_img_list[i] = img_t;
									}
									
									// 存储的下拉列表
									temp_xiala_list[i] = [];
									if((temp_data_list[i].field_info.xiala || null != null) && temp_data_list[i].field_info.xiala.length > 0){
										temp_xiala_list[i] = temp_data_list[i].field_info.xiala;
									}
								}
								this.setData({
								    province_id: temp_province,
								    city_id: temp_city,
								    county_id: temp_county,
									yxfile:temp_img_list,
									yxxiala:temp_xiala_list
								});
								console.log(this.yxfile);
								if(i_arr || null != null){
									i_arr.forEach((d, i) => {
									    // 获取城市、区县
									    self.get_city_list(d);
									    self.get_county_list(d);
									});
								}
							}
							// 半秒后初始化数据
							setTimeout(function() {
								self.get_region_data();
								self.get_xiala_data();
							}, 1200);
                        } else {
                            self.setData({
                                data_list_loding_status: 0,
                                data_bottom_line_status: false,
                                data_list_loding_msg: res.data.msg
                            });
                            if (app.globalData.is_login_check(res.data, self, 'init')) {
                                app.globalData.showToast(res.data.msg);
                            }
                        }
                    },
                    fail: () => {
                        uni.hideLoading();
                        uni.stopPullDownRefresh();
                        self.setData({
                            data_list_loding_status: 2,
                            data_bottom_line_status: false,
                            data_list_loding_msg: this.$t('common.internet_error_tips')
                        });
                        app.globalData.showToast(this.$t('common.internet_error_tips'));
                    }
                });
            },
			
			// 选择地理位置
			choose_location_event(e) {
				var lng = e.currentTarget.dataset.lng;
				var lat = e.currentTarget.dataset.lat;
				var str = '';
				if(parseFloat(lng) > 0 && parseFloat(lat) > 0)
				{
					str = '?lng='+lng+'&lat='+lat;
				}
				uni.setStorageSync('adr_field_info', e);
				var self = this;
				setTimeout(function() {
					self.chose_addr_flag = 1;
					app.globalData.url_open('/pages/common/open-setting-location/open-setting-location'+str);
				}, 200);
			},
			
			// 地址信息初始化
			user_location_init() {
				var self = this;
				uni.getStorage({
					key: 'adr_field_info',
					success: function (res) {
						// 获取选择的地址信息
						var result = uni.getStorageSync(self.user_location_cache_key) || null;
						var data = '';
						if (result != null) {
							data += ((result.name || null) != null) ? result.name+',' : '';
							data += ((result.address || null) != null) ? result.address+',' : '';
							data += ((result.longitude || null) != null) ? result.longitude+',' : '';
							data += ((result.latitude || null) != null) ? result.latitude : '';
							
							// 组装数据，保存
							var e = res.data;
							var detail = {};
							detail['value'] = data;
							e['detail'] = detail;
							self.PluginsyxformplusSave(e);
						}
					},
					complete: function (res) {
						uni.removeStorage({
						    key: 'adr_field_info'
						});
						uni.removeStorage({
						    key: self.user_location_cache_key
						});
					}
				});
			},

            // yxformplus ---------------------------- begin
            // 初始化时，整理已存的表单地址数据
            get_region_data(e){
            	var self = this;
            	var temp_province_list = [];
            	if(this.plugins_yxformplus_data || null != null){
            		var temp_data_list = this.plugins_yxformplus_data[0].form_data || null;
            		if(temp_data_list != null){
            			// 先初始化
            			var temp_province_value = [];
            			var temp_city_value = [];
            			var temp_county_value = [];
            			for (var i in temp_data_list) {
            			    if (temp_province_value[i] == undefined) {
            			        temp_province_value[i] = '';
            			    }
            				if (temp_city_value[i] == undefined) {
            				    temp_city_value[i] = '';
            				}
            				if (temp_county_value[i] == undefined) {
            				    temp_county_value[i] = '';
            				}
            			}
            			this.setData({
            			    province_value: temp_province_value,
            			    city_value: temp_city_value,
            			    county_value: temp_county_value
            			});
            			
            			for (var i in temp_data_list) {
            				if(parseInt(temp_data_list[i]['type']) == 12){
            					self.init_region_value(i);
            				}
            			}
            		}
            	}
            },
            // 初始化时，整理已存的表单下拉数据
            get_xiala_data(e){
            	var self = this;
            	var temp_province_list = [];
            	if(this.plugins_yxformplus_data || null != null){
            		var temp_data_list = this.plugins_yxformplus_data[0].form_data || null;
            		if(temp_data_list != null){
            			// 先初始化yxxiala_value
            			var temp_list = [];
            			for (var i in temp_data_list) {
            			    if (temp_list[i] == undefined) {
            			        temp_list[i] = '';
            			    }
            			}
            			this.setData({
            			    yxxiala_value: temp_list,
            			});
            			
            			for (var i in temp_data_list) {
            				if(parseInt(temp_data_list[i]['type']) == 6){
            					self.init_xiala_value(i);
            				}
            			}
            		}
            	}
            },
            
            // 单个操作时校验，校验通过修改moren字段(用于提交订单时整体遍历校验)，同时保存该字段
            yxblur(e){
            	var is_must = e.currentTarget.dataset.is_must;
            	var value = e.detail.value;
            	var msg = e.currentTarget.dataset.validationMessage;
            	var title = e.currentTarget.dataset.title;
            	var type_id = e.currentTarget.dataset.typeId;
            	var minlength = e.currentTarget.dataset.minlength;
            	var maxlength = e.currentTarget.dataset.maxlength;
            	var key = e.currentTarget.dataset.index;
            	if(parseInt(is_must) == 1){
            		if(value === '')
            		{
            			app.globalData.showToast(msg || title+'不能为空');
            			return false;
            		} else {
            			// 校验过了是否必填，再校验大小，在类型为货币金钱时需要，为整数时，也如此校验大小
            			if(parseInt(type_id) == 11 || parseInt(type_id) == 3)
            			{
							if((parseFloat(minlength) > 0 && parseFloat(minlength) > parseFloat(value)) || (parseFloat(maxlength) > 0 && parseFloat(maxlength) < parseFloat(value))){
            					app.globalData.showToast(msg || '金额输入不正确');
            					return false;
            				}
            			} else {
            				// 为文本时，单行文本，多行文本，看长度是否符合要求
            				if(parseInt(minlength) > 0 && value.length < parseInt(minlength)){
            					app.globalData.showToast(title+'长度不能小于'+minlength);
            					return false;
            				}
            				if(parseInt(maxlength) > 0 && value.length > parseInt(maxlength)){
            					app.globalData.showToast(title+'长度不能大于'+maxlength);
            					return false;
            				}
            			}
            		}
            	}
            	
            	// 保存
            	this.PluginsyxformplusSave(e);
            },
            // 单选多选
            yxonclick(e){
            	var is_must = e.currentTarget.dataset.is_must;
            	var value = e.detail.value;
            	var msg = e.currentTarget.dataset.validationMessage;
            	var title = e.currentTarget.dataset.title;
            	var type_id = e.currentTarget.dataset.typeId;
            	if(parseInt(type_id)==5){
            		value = value.join(",");//多选的值转化为字符串
            	}
            	if(parseInt(is_must) == 1){
            		if(value === '')
            		{
            			app.globalData.showToast(msg || title+'必选');
            			return false;
            		}
            	}
            	e.detail.value = value;
            	// 保存
            	this.PluginsyxformplusSave(e);
            },
            // 下拉
            yxselect(e){
            	var index = parseInt(e.detail.value) || 0;// 数组序号
            	var key = e.currentTarget.dataset.index;//字段在总的字段列表集中的序号
            	var value = null;
            	if (index >= 0) {
            	    var data = this.yxxiala[key][index];
            		var temp_yxxiala_value = this.yxxiala_value;
            		temp_yxxiala_value[key] = index;//选中的数组序号
            		value = data.value;
            	    this.setData({
            	        yxxiala_value: temp_yxxiala_value,
            	    });
            	}
            	var is_must = e.currentTarget.dataset.is_must;
            	var msg = e.currentTarget.dataset.validationMessage;
            	var title = e.currentTarget.dataset.title;
            	var type_id = e.currentTarget.dataset.typeId;
            	if(parseInt(is_must) == 1){
            		if(value === '' || value == null)
            		{
            			app.globalData.showToast(msg || title+'必选');
            			return false;
            		}
            	}
            	e.detail.value = value;
            	// 保存
            	this.PluginsyxformplusSave(e);
            },
            bindDateChange(e){
            	var is_must = e.currentTarget.dataset.is_must;
            	var value = e.detail.value;
            	var msg = e.currentTarget.dataset.validationMessage;
            	var title = e.currentTarget.dataset.title;
            	if(parseInt(is_must) == 1){
            		if(value === '')
            		{
            			app.globalData.showToast(msg || title+'不能为空');
            			return false;
            		}
            	}
				
				// 检测是否是慢递字段
				var order_data_id = e.currentTarget.dataset.id;
				var self = this;
				var key = e.currentTarget.dataset.index;
				uni.showLoading({
				    title: this.$t('common.loading_in_text'),
				});
				this.setData({
				    data_list_loding_status: 1
				});
				uni.request({
				    url: app.globalData.get_request_url("checksome", "index", "mandi"),
				    method: 'POST',
				    data: {
				        id: order_data_id,
				        goods_id: this.params.goods_id
				    },
				    dataType: 'json',
				    success: res => {console.log(res);
				        uni.hideLoading();
				        uni.stopPullDownRefresh();
				        if (res.data.code == 0) {
							// 为0表明是慢递时间字段，且允许修改
				            uni.showModal({
				                title: '温馨提示',
				                content: '修改该字段后，无论是否点击保存表单，都将改变订单最终价格，确定修改吗？',
				                confirmText: '确定',
				                cancelText: '暂不',
				                success: result => {
									// 点击确定后走慢递保存时间字段的路线
				                    if (result.confirm) {
										var mandi_data = {};
										mandi_data['id'] = order_data_id;
										mandi_data['goods_id'] = this.params.goods_id;
										mandi_data['content'] = value;
										mandi_data['is_admin_access'] = 0;
										uni.showLoading({
										    title: '处理中...'
										});
										uni.request({
										    url: app.globalData.get_request_url('formsave', 'index', 'mandi'),
										    method: 'POST',
										    data: mandi_data,
										    dataType: 'json',
										    success: res => {console.log(res);
										        uni.hideLoading();
										        if (res.data.code == 0) {
													// 成功保存到服务器后，修改本地moren字段
													var temp_data = self.plugins_yxformplus_data || null;
													
													temp_data[0].form_data[key].field_info.moren = value;
													self.setData({
													    plugins_yxformplus_data: temp_data
													});
										        } else {
										            //app.globalData.showToast(res.data.msg);
										        }
										    },
										    fail: () => {
										        uni.hideLoading();
										        app.globalData.showToast(this.$t('common.internet_error_tips'));
										    }
										});
				                    }
				                }
				            });
				        } else {
							// 禁制修改，进行提示
				            if (res.data.code == 101) {
								app.globalData.showToast(res.data.msg);
							}else{
								// 其他情况正常走表单保存
								self.PluginsyxformplusSave(e);
							}
				        }
				    },
				    fail: () => {
				        uni.hideLoading();
				        uni.stopPullDownRefresh();
				        self.setData({
				            data_list_loding_status: 2,
				            data_bottom_line_status: false,
				            data_list_loding_msg: this.$t('common.internet_error_tips')
				        });
				        app.globalData.showToast(this.$t('common.internet_error_tips'));
				    }
				});
            },
            
            // 整体遍历校验表单，校验通过则保存每个字段
            PluginsyxformplusCheck(){
            	var e = {};
            	var currentTarget = {};
            	var dataset = {};
            	var detail = {};
            	var msg = '';
            	var lastform = this.plugins_yxformplus_data[0].form_data || null;
            	var fail = 0;
            	if(lastform != null){
            		for (var i in lastform) {
            			// 一个个的来获取值，并校验
            			msg = lastform[i].name+'不能为空';
            			if(parseInt(lastform[i].type) == 4 || parseInt(lastform[i].type) == 5 || parseInt(lastform[i].type) == 6 ||parseInt(lastform[i].type) == 7 || parseInt(lastform[i].type) == 8 || parseInt(lastform[i].type) == 12){
            				msg = lastform[i].name+'必选';
            			}else if(parseInt(lastform[i].type) == 9 || parseInt(lastform[i].type) == 10){
            				msg = lastform[i].name+'必须上传';
            			}else if(parseInt(lastform[i].type) == 11){
            				msg = '请输入正确的'+lastform[i].name;
            			}
            			// 地址类
            			if(parseInt(lastform[i].type) == 12 && parseInt(lastform[i].field_info.is_must) === 1){
            				var sss = lastform[i].field_info.moren.split(",");
            				if(parseInt(sss[0]) === 0 || parseInt(sss[1]) === 0 || parseInt(sss[2]) === 0){
            					app.globalData.showToast(msg);
            					fail++;
            					break;
            				}
            			}else{
            				if(parseInt(lastform[i].field_info.is_must) === 1 && lastform[i].field_info.moren == ''){
            					app.globalData.showToast(msg);
            					fail++;
            					break;
            				}
            			}
            			
            			// 组装数据，保存
            			dataset['index'] = i;
            			dataset['typeId'] = lastform[i].field_info.type;
            			dataset['formId'] = lastform[i].field_info.sid;
            			dataset['fieldId'] = lastform[i].field_info.id;
						dataset['id'] = lastform[i].id;
            			dataset['title'] = lastform[i].field_info.name;
            			currentTarget['dataset'] = dataset;
            			e['currentTarget'] = currentTarget;
            			
            			detail['value'] = lastform[i].field_info.moren;
            			e['detail'] = detail;
						e['isall'] = 1;
            			console.log(e);
            			this.PluginsyxformplusSave(e);
            		}
            	}
            	return fail;
            },
            
            // 表单提交
            PluginsyxformplusSave(e){
            	var self = this;
            	var key = e.currentTarget.dataset.index;
            	var type_id = e.currentTarget.dataset.typeId;
            	var value = e.detail.value;
				var isall = e.isall || 0;
            	var data = {
            		"form_id": e.currentTarget.dataset.formId,
					"id": e.currentTarget.dataset.id,
					"is_admin_access": 0,
            		"field_id": e.currentTarget.dataset.fieldId,
            		"type_id": type_id,
            		"goods_id":this.params.goods_id,
            		"title": e.currentTarget.dataset.title,
            		"content": value,
					"isall":isall
            	};
            	
            	uni.showLoading({
            	    title: '处理中...'
            	});
            	uni.request({
            	    url: app.globalData.get_request_url('ordersave', 'index', 'yxformplus'),
            	    method: 'POST',
            	    data: data,
            	    dataType: 'json',
            	    success: res => {console.log(res);
            	        uni.hideLoading();
            	        if (res.data.code == 0) {
            	            // 成功保存到服务器后，修改本地moren字段
            	            var temp_data = self.plugins_yxformplus_data || null;
            				
            				temp_data[0].form_data[key].field_info.moren = value;
            	            self.setData({
            	                plugins_yxformplus_data: temp_data
            	            });
            	        } else {
            	            app.globalData.showToast(res.data.msg);
            	        }
            	    },
            	    fail: () => {
            	        uni.hideLoading();
            	        app.globalData.showToast(this.$t('common.internet_error_tips'));
            	    }
            	});
            },
            
            // 地区数据初始化
            init_region_value(i) {
            	var temp_province_value = this.province_value;
            	var temp_city_value = this.city_value;
            	var temp_county_value = this.county_value;
            	temp_province_value[i] = this.get_region_value("province_list", "province_id",i);
            	temp_city_value[i] = this.get_region_value("city_list", "city_id",i);
            	temp_county_value[i] = this.get_region_value("county_list", "county_id",i);
                this.setData({
                    province_value: temp_province_value,
                    city_value: temp_city_value,
                    county_value: temp_county_value
                });
            },
            // 下拉数据初始化
            init_xiala_value(i) {
            	var temp_xiala_value = this.yxxiala_value;// 下拉对应所在数组中的序号
            	var data = this.plugins_yxformplus_data[0].form_data[i].field_info.xiala || null;
            	var data_id = this.plugins_yxformplus_data[0].form_data[i].moren || 0;
            	var value = null;
            	if(data != null){
            		data.forEach((d, i) => {
            		    if (d.value == data_id) {
            		        value = i;
            		        return false;
            		    }
            		});
            	}
            	temp_xiala_value[i] = value;
                this.setData({
                    yxxiala_value: temp_xiala_value
                });
            },
            
            // 地区初始化匹配索引
            get_region_value(list, id, i) {
                var data = this[list][i];
                var data_id = this[id][i];
                var value = null;
                data.forEach((d, i) => {
                    if (d.id == data_id) {
                        value = i;
                        return false;
                    }
                });
                return value;
            },
            
            // 获取省份
            get_province_list() {
                uni.request({
                    url: app.globalData.get_request_url("index", "region"),
                    method: 'POST',
                    data: {},
                    dataType: 'json',
                    success: res => {
                        if (res.data.code == 0) {
                            var data = res.data.data;
            				// 给省份自动赋予省份全值
            				var temp_province_list = [];
            				if(this.plugins_yxformplus_data || null != null){
            					var temp_data_list = this.plugins_yxformplus_data[0].form_data || null;
            					if(temp_data_list != null){
            						for (var i in temp_data_list) {
            							if(parseInt(temp_data_list[i]['type']) == 12){
            								temp_province_list[i] = data;
            							}else{
            								temp_province_list[i] = [];
            							}
            						}
            					}
            				}
                            this.setData({
                                province_list: temp_province_list
                            });
                        } else {
                            app.globalData.showToast(res.data.msg);
                        }
                    },
                    fail: () => {
                        app.globalData.showToast("省份获取失败");
                    }
                });
            },
            
            // 获取市
            get_city_list(i) {
            	var self = this;
                if (this.province_id[i]) {
                    uni.request({
                        url: app.globalData.get_request_url("index", "region"),
                        method: 'POST',
                        data: {
                            pid: this.province_id[i]
                        },
                        dataType: 'json',
                        success: res => {
                            if (res.data.code == 0) {
                                var data = res.data.data;
            					var temp_city_list = [];
            					if(this.plugins_yxformplus_data || null != null){
            						var temp_data_list = this.plugins_yxformplus_data[0].form_data || null;
            						if(temp_data_list != null){
            							for (var ii in temp_data_list) {
            								if(parseInt(i) === parseInt(ii)){
            									temp_city_list[ii] = data;
            								}else{
            									if((self.city_list[ii] || null != null) && self.city_list[ii].length > 0){
            										temp_city_list[ii] = self.city_list[ii];
            									}else{
            										temp_city_list[ii] = [];
            									}
            								}
            							}
            						}
            					}
                                this.setData({
                                    city_list: temp_city_list
                                });
                            } else {
                                app.globalData.showToast(res.data.msg);
                            }
                        },
                        fail: () => {
                            app.globalData.showToast("城市获取失败");
                        }
                    });
                }
            },
            
            // 获取区/县
            get_county_list(i) {
            	var self = this;
                if (this.city_id[i]) {
                    // 加载loding
                    uni.request({
                        url: app.globalData.get_request_url("index", "region"),
                        method: 'POST',
                        data: {
                            pid: this.city_id[i]
                        },
                        dataType: 'json',
                        success: res => {
                            if (res.data.code == 0) {
                                var data = res.data.data;
            					var temp_county_list = [];
            					if(this.plugins_yxformplus_data || null != null){
            						var temp_data_list = this.plugins_yxformplus_data[0].form_data || null;
            						if(temp_data_list != null){
            							for (var ii in temp_data_list) {
            								if(parseInt(i) === parseInt(ii)){
            									temp_county_list[ii] = data;
            								}else{
            									if((self.county_list[ii] || null != null) && self.county_list[ii].length > 0){
            										temp_county_list[ii] = self.county_list[ii];
            									}else{
            										temp_county_list[ii] = [];
            									}
            								}
            							}
            						}
            					}
                                this.setData({
                                    county_list: temp_county_list
                                });
                            } else {
                                app.globalData.showToast(res.data.msg);
                            }
                        },
                        fail: () => {
                            app.globalData.showToast("区/县获取失败");
                        }
                    });
                }
            },
            
            // 省份事件
            select_province_event(e) {
                var index = e.detail.value || 0;// 数组序号
            	var key = e.currentTarget.dataset.index;//字段在总的字段列表集中的序号
                if (index >= 0) {
                    var data = this.province_list[key][index];
            		var temp_province_value = this.province_value;
            		temp_province_value[key] = index;
            		var temp_province_id = this.province_id;
            		temp_province_id[key] = data.id;
					var temp_city_value = this.city_value;
					temp_city_value[key] = [];
					var temp_county_value = this.county_value;
					temp_county_value[key] = [];
					var temp_city_id = this.city_id;
					temp_city_id[key] = [];
					var temp_county_id = this.county_id;
					temp_county_id[key] = [];
                    this.setData({
                        province_value: temp_province_value,
                        province_id: temp_province_id,
                        city_value: temp_city_value,
                        county_value: temp_county_value,
                        city_id: temp_city_id,
                        county_id: temp_county_id
                    });
                    this.get_city_list(key);
            		
            		// 选中省份后，保存一下，组装省市区字符串
            		e.detail.value = data.id+',0,0';
            		// 保存
            		this.PluginsyxformplusSave(e);
                }
            },
            
            // 市事件
            select_city_event(e) {
                var index = e.detail.value || 0;
            	var key = e.currentTarget.dataset.index;
                if (index >= 0) {
                    var data = this.city_list[key][index];
            		var temp_city_value = this.city_value;
            		temp_city_value[key] = index;
            		var temp_city_id = this.city_id;
            		temp_city_id[key] = data.id;
					var temp_county_value = this.county_value;
					temp_county_value[key] = [];
					var temp_county_id = this.county_id;
					temp_county_id[key] = [];
                    this.setData({
                        city_value: temp_city_value,
                        city_id: temp_city_id,
                        county_value: temp_county_value,
                        county_id: temp_county_id
                    });
                    this.get_county_list(key);
            		
            		// 选中省份后，保存一下，组装省市区字符串
            		e.detail.value = this.province_id[key]+','+data.id+',0';
            		// 保存
            		this.PluginsyxformplusSave(e);
                }
            },
            
            // 区/县事件
            select_county_event(e) {
                var index = e.detail.value || 0;
            	var key = e.currentTarget.dataset.index;
                if (index >= 0) {
                    var data = this.county_list[key][index];
            		var temp_county_value = this.county_value;
            		temp_county_value[key] = index;
            		var temp_county_id = this.county_id;
            		temp_county_id[key] = data.id;
                    this.setData({
                        county_value: temp_county_value,
                        county_id: temp_county_id
                    });
            		
            		// 选中省份后，保存一下，组装省市区字符串
            		e.detail.value = this.province_id[key]+','+this.city_id[key]+','+data.id;
            		// 保存
            		this.PluginsyxformplusSave(e);
                }
            },
            
            // 省市区未按照顺序选择提示
            region_select_error_event(e) {
                var value = e.currentTarget.dataset.value || null;
                if (value != null) {
                    app.globalData.showToast(value);
                }
            },
            
            // 上传图片预览
            upload_show_event(e) {
                var index = e.currentTarget.dataset.index;
                var ix = e.currentTarget.dataset.ix;
                
				if(app.globalData.is_android())
				{
					var self = this;
					uni.previewImage({
					    current: self.yxfile[index][ix],
					    urls: self.yxfile[index],
						longPressActions: {
							itemList: [self.$t('fengcheche.fcctips.t9')],
							success: function(data) {
								uni.closePreviewImage();
								self.peraction = 'previewImage';
								self.permissionID = 'WRITE_EXTERNAL_STORAGE';
								setTimeout(()=>{
									self.$refs['authpup'].open(self.yxfile[index][ix]);
								},500);
							},
							fail: function(err) {
								console.log(err.errMsg);
							}
						}
					});
				}else{
					uni.previewImage({
					    current: this.yxfile[index][ix],
					    urls: this.yxfile[index]
					});
				}
            },
            
            // 图片删除
            upload_delete_event(e) {
                var index = e.currentTarget.dataset.index;
                var ix = e.currentTarget.dataset.ix;
                var self = this;
                uni.showModal({
                    title: '温馨提示',
                    content: '删除后不可恢复、继续吗？',
                    success(res) {
                        if (res.confirm) {
            				// 可做远程删除，结果成功后执行下面的本地删除
                            var list = self.yxfile;
                            list[index].splice(ix, 1);
                            self.setData({
                                yxfile: list
                            });
							
							// 改写当前结果，保存
							var lastr = '';
							for (var ii in list[index]) {
								if(lastr == ''){
									lastr = list[index][ii];
								}else{
									lastr += ','+list[index][ii];
								}
							}
							e.detail.value = lastr;
							e['isall'] = 1;//动真格的
							// 保存
							self.PluginsyxformplusSave(e);
                        }
                    }
                });
            },
            
            // 文件上传
			file_upload_event(e) {
				if(app.globalData.is_android())
				{
					this.permissionID = 'CAMERA';
					setTimeout(()=>{
						this.$refs['authpup'].open(e);
					},500);
				}else{
					this.file_upload_event_true(e);
				}
			},
			// #ifdef APP-PLUS
			//用户授权权限后的回调
			changeAuth(e){
				if(this.permissionID == 'WRITE_EXTERNAL_STORAGE')
				{
					if(this.peraction == 'previewImage')
					{
						app.globalData.save_image_by_url(e);
					}else{
						this.file_upload_event_true(e);
					}
				}else{
					// 第一次是摄像头返回，再返回是相册权限，然后才继续执行
					this.peraction = 'fileupload';
					this.permissionID = 'WRITE_EXTERNAL_STORAGE';
					setTimeout(()=>{
						this.$refs['authpup'].open(e);
					},500);
				}
			},
			// #endif
            file_upload_event_true(e) {
            	if(!app.globalData.is_single_page_check()) {
            	    return false;
            	}
            	var user = app.globalData.get_user_info(this, 'init');
            	if (user != false) {
					// 数据初始化
					var index = e.currentTarget.dataset.index;
					var temp_list = this.yxfile;
					var maxnum = parseInt(e.currentTarget.dataset.maxNumber);
					var file_type = e.currentTarget.dataset.file_type;
					// 处理上传文件
					var self = this;
					if(file_type=='images'){
						uni.chooseImage({
							//count: maxnum,
							success(res) {
								var success = 0;
								var fail = 0;
								var length = res.tempFilePaths.length;
								var count = 0;
								self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length,maxnum,file_type,e);
							}
						});
					}else if(file_type=='video'){
						uni.chooseVideo({
							success(res) {
								var success = 0;
								var fail = 0;
								var length = 1;//res.tempFilePath.length;
								var count = 0;
								self.upload_one_by_one(index, res.tempFilePath, success, fail, count, length,maxnum,file_type,e);
							}
						});
					}else{
						// #ifdef H5
						uni.chooseFile({
							//count: maxnum,
							success(res) {console.log(res);
								var success = 0;
								var fail = 0;
								var length = res.tempFilePaths.length;
								var count = 0;
								self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length,maxnum,file_type,e);
							}
						});
						// #endif
						// #ifdef MP-WEIXIN
						//从微信聊天会话中选择文件
						wx.chooseMessageFile({
							count: maxnum,
							type:'file',
							success(res) {console.log(res);
								var success = 0;
								var fail = 0;
								var length = res.tempFiles.length;
								var count = 0;
								// 微信这个tempFiles是对象，需要给其中的路径取出来，组装成新的数组，以适配upload_one_by_one方法
								var temp_files = [];
								for (var ii in res.tempFiles) {
									temp_files[ii] = res.tempFiles[ii].path;
								}
								self.upload_one_by_one(index, temp_files, success, fail, count, length,maxnum,file_type,e);
							}
						});
						// #endif
						// #ifndef H5 || MP-WEIXIN
						app.globalData.showToast('当前端不支持文件上传');
						// #endif
					}
            	}
            },
            
            // 采用递归的方式上传多张
            upload_one_by_one(index, img_paths, success, fail, count, length,maxnum,file_type,e) {
                var self = this;
            	var file_action = '';
            	if(file_type=='images'){
            		file_action = 'uploadimage';
            	}else if(file_type=='video'){
            		file_action = 'uploadvideo';
            	}else{
            		file_action = 'uploadfile';
            	}
                if ((self.yxfile[index] || null) == null || self.yxfile[index].length < maxnum) {
                    uni.uploadFile({
                        url: app.globalData.get_request_url("index", "ueditor"),
                        filePath: (file_type=='video') ? img_paths : img_paths[count],
                        name: 'upfile',
                        formData: {
                            action: file_action,
                            path_type: self.editor_path_type
                        },
                        success: function(res) {
                            success++;
                            if (res.statusCode == 200) {
                                var data = typeof res.data == 'object' ? res.data : JSON.parse(res.data);
                                if (data.code == 0 && (data.data.url || null) != null) {
                                    var list = self.yxfile;
                                    if ((list[index] || null) == null) {
                                        list[index] = [];
                                    }
                                    list[index].push(data.data.url);
                                    self.setData({
                                        yxfile: list
                                    });
            						// 改写当前结果，保存
            						var lastr = '';
            						for (var ii in list[index]) {
            							if(lastr == ''){
            								lastr = list[index][ii];
            							}else{
            								lastr += ','+list[index][ii];
            							}
            						}
            						e.detail.value = lastr;
            						// 保存
            						self.PluginsyxformplusSave(e);
                                } else {
                                    app.globalData.showToast(data.msg);
                                }
                            }
                        },
                        fail: function(e) {
                            fail++;
                        },
                        complete: function(e) {
                            count++;
                            // 下一张
                            if (count >= length) {
                                // 上传完毕，作一下提示
                                //app.showToast('上传成功' + success +'张', 'success');
                            } else {
                                // 递归调用，上传下一张
                                self.upload_one_by_one(index, img_paths, success, fail, count, length,maxnum,file_type);
                            }
                        }
                    });
                }
            },
			
			// 确认
			goods_buy_confirm_event(e) {
				var self = this;
				uni.showModal({
				    title: '温馨提示',
				    content: '仅有一次编辑机会，请确认您的数据准确，确定吗？',
				    confirmText: '确认',
				    cancelText: '暂不',
				    success: result => {
				        uni.stopPullDownRefresh();
				        if (result.confirm) {
							// 校验所有自定义表单，同时再进行一次保存
							if(self.PluginsyxformplusCheck() > 0){
								return false;
							}
							
				            uni.showLoading({
				                title: '处理中...'
				            });
				            uni.request({
				                url: app.globalData.get_request_url('saveall', 'index', 'yxformplus'),
				                method: 'POST',
				                data: {
									order_data_ids: self.plugins_yxformplus_data[0].order_data_ids
								},
				                dataType: 'json',
				                success: res => {
				                    uni.hideLoading();
				                    if (res.data.code == 0) {
				                        app.globalData.url_open('/pages/user-order-detail/user-order-detail?id=' + self.params.id);
				                    } else {
				                        app.globalData.showToast(res.data.msg);
				                    }
				                },
				                fail: () => {
				                    uni.hideLoading();
				                    app.globalData.showToast(this.$t('common.internet_error_tips'));
				                }
				            });
				        }
				    }
				});
			}
            // yxformplus------------------------end
        }
    };
</script>
<style>
    @import './form-edit.css';
</style>